<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :span="6" v-if="indexData.isAgent == 0">
        <router-link :to="'/agent/list'" style="margin-right: 10px;">
          <div class="grid-content bg-blue">
            <span class="title">代理数量</span>
            <div class="count">{{indexData.agentCount}}<span style="font-size: 22px;"> 个</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/credit/card/list'" style="margin-right: 10px;">
          <div class="grid-content bg-orange">
            <span class="title">管理信用卡总额度</span>
            <div class="count">{{indexData.totalLimit}}<span style="font-size: 22px;"> 个</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/credit/card/list'" style="margin-right: 10px;">
          <div class="grid-content bg-green">
            <span class="title">管理信用卡数量</span>
            <div class="count">{{indexData.cardCount}}<span style="font-size: 22px;"> 个</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <div class="grid-content bg-red">
          <span class="title">业务员数量</span>
          <div class="count">{{indexData.businessCount}}<span style="font-size: 22px;"> 个</span></div>
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6">
        <router-link :to="'/bill/out/record'" style="margin-right: 10px;">
          <div class="grid-content bg-blue">
            <span class="title">今日总需出账金额</span>
            <div class="count">{{indexData.todayNeedOutMoney}}<span style="font-size: 22px;"> 元</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/bill/in/record'" style="margin-right: 10px;">
          <div class="grid-content bg-orange">
            <span class="title">今日总需进账金额</span>
            <div class="count">{{indexData.todayNeedInMoney}}<span style="font-size: 22px;"> 元</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/bill/out/record'" style="margin-right: 10px;">
          <div class="grid-content bg-green">
            <span class="title">今日已出账金额</span>
            <div class="count">{{indexData.todayOutMoney}}<span style="font-size: 22px;"> 元</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/bill/in/record'" style="margin-right: 10px;">
          <div class="grid-content bg-red">
            <span class="title">今日已进账金额</span>
            <div class="count">{{indexData.todayInMoney}}<span style="font-size: 22px;"> 元</span></div>
          </div>
        </router-link>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6">
        <div class="grid-content bg-blue">
          <span class="title">累积总利润</span>
          <div class="count">{{indexData.totalProfit}}<span style="font-size: 22px;"> 元</span></div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content bg-orange">
          <span class="title">今日总利润</span>
          <div class="count">{{indexData.todayProfit}}<span style="font-size: 22px;"> 元</span></div>
        </div>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/bill/out/record'" style="margin-right: 10px;">
          <div class="grid-content bg-green">
            <span class="title">今日需出账笔数</span>
            <div class="count">{{indexData.todayOutCount}}<span style="font-size: 22px;"> 笔</span></div>
          </div>
        </router-link>
      </el-col>
      <el-col :span="6">
        <router-link :to="'/bill/in/record'" style="margin-right: 10px;">
          <div class="grid-content bg-red">
            <span class="title">今日需进账笔数</span>
            <div class="count">{{indexData.todayInCount}}<span style="font-size: 22px;"> 笔</span></div>
          </div>
        </router-link>
      </el-col>
    </el-row>
    <el-divider />
  </div>
</template>

<script setup name="Index" lang="ts">

import {IndexDataVO} from "@/api/credit/dataview/types";

import {getIndexData} from "@/api/credit/dataview";

const indexData = reactive<IndexDataVO>({

  isAgent:undefined,
  /**
   *  代理数量
   */
  agentCount:undefined,
  /**
   *  管理的信用卡总数量
   */
  cardCount:undefined,

  /**
   *  管理的信用卡的总额度
   */
  totalLimit:undefined,

  /**
   *  今日总需出账金额
   */
  todayNeedOutMoney:undefined,

  /**
   *  今日总需进账金额
   */
  todayNeedInMoney:undefined,

  /**
   *  今日已出账金额
   */
  todayOutMoney:undefined,

  /**
   *  今日已进账金额
   */
  todayInMoney:undefined,

  /**
   *  今日总利润
   */
  todayProfit:undefined,

  /**
   *  累积总利润
   */
  totalProfit:undefined,

  /**
   *  业务员数量
   */
  businessCount:undefined,
  todayOutCount:undefined,
  todayInCount:undefined,
})



const getIndexViewData = async ()=>{
  const res = await getIndexData();
  console.log('getIndexViewData',res.data)
  Object.assign(indexData, res.data);
}


onMounted(() => {
  getIndexViewData();
});

const goTarget = (url:string) => {
  window.open(url, '__blank')
}
</script>

<style scoped lang="scss">

.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }


  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-green {
    background: #67C23A;
  }
  .bg-blue {
    background: #2d8df1;
  }
  .bg-orange {
    background: #E6A23C;
  }

  .bg-red {
    background: #F56C6C;
  }

  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 130px;
    padding: 10px;margin-top: 10px;
    cursor: pointer;
  }

  .grid-content .title{
    font-size: 28px;
    font-weight: bold;
    color:white;
    text-align: right;
    margin: 10px;
  }

  .grid-content .count{
    font-size: 32px;
    font-weight: bold;
    color: #b04040;
    margin: 10px 40px;
    text-align: right;
  }

  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }

  .title-un-sign{
    display: flex;
    margin: 10px;
    font-size: 25px;
  }


}
</style>
